﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;

namespace IXION.BLOG.COMMON.PASSWORD
{
    public class PasswordUtils
    {
        /// <summary>
        /// 获取MD5摘要
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string MD5(string str)
        {
            if (String.IsNullOrEmpty(str))
            {
                return null;
            }
            var key = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
            return key == null ? null : key.ToLower();
        }
        /// <summary>
        /// 获取sha1摘要
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string SHA1(string str)
        {
            if (String.IsNullOrEmpty(str))
            {
                return null;
            }

            var key = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
            return key == null ? null : key.ToLower();
        }
    }
}